<html>
<head><meta charset="utf-8"><title>Priority order of lints · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html">Priority order of lints</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225983716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Priority%20order%20of%20lints/near/225983716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshitomo Nakanishi <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html#225983716">(Feb 11 2021 at 12:38)</a>:</h4>
<p>We may need to work on the problem discussed in <a href="https://github.com/rust-lang/rust-clippy/pull/6716#discussion_r574312592">here</a>.<br>
I think this is NOT specific to this issue. I'm glad to hear opinions.</p>



<a name="225986953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Priority%20order%20of%20lints/near/225986953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html#225986953">(Feb 11 2021 at 13:11)</a>:</h4>
<p>See <a href="#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span/near/214517130">https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/multiple.20lints.20targeting.20the.20same.20span/near/214517130</a> for previous discussion about this.</p>



<a name="225987953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Priority%20order%20of%20lints/near/225987953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html#225987953">(Feb 11 2021 at 13:19)</a>:</h4>
<p>Generally speaking, we don't want to lint twice on the same span. If that could happen, we want to trigger the lint with the "better" suggestion. We do this with a construct like: <code>if !lint_A_triggered { check_lint_B }</code>. If lint B depends on multiple lints, this can be done with:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">linted</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">check_lint_A</span><span class="p">();</span><span class="w"></span>
<span class="n">linted</span><span class="w"> </span><span class="o">|=</span><span class="w"> </span><span class="n">check_lint_B</span><span class="p">();</span><span class="w"></span>
<span class="o">..</span><span class="p">.</span><span class="w"></span>

<span class="k">if</span><span class="w"> </span><span class="o">!</span><span class="n">linted</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">check_lint_XYZ</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>What you linked seems fishy to me though, because of the short circuiting.</p>



<a name="226087069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Priority%20order%20of%20lints/near/226087069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshitomo Nakanishi <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html#226087069">(Feb 12 2021 at 02:39)</a>:</h4>
<p>Thanks!  Your solution proposed at the topic seems nice to me. Is it any problem to implement it?</p>



<a name="226097032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Priority%20order%20of%20lints/near/226097032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Yoshitomo Nakanishi <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html#226097032">(Feb 12 2021 at 04:26)</a>:</h4>
<blockquote>
<p>Is it any problem to implement it?</p>
</blockquote>
<p>oops, I mean "Is there any problem to implement it?"</p>



<a name="226106981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/Priority%20order%20of%20lints/near/226106981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/Priority.20order.20of.20lints.html#226106981">(Feb 12 2021 at 08:03)</a>:</h4>
<p>Except for the <code>allow</code> problem, I don't know of any other problems.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>